<template>
	<view class="card cardConent">
		<view class="flex jcsb aic">
			<navCard class="mgb40" ref="navcard" />
			<van-button type="primary" size="small" class="mgr40">退出登录</van-button>
		</view>
		<van-cell-group v-for="i in cellList">
			<van-cell :title="i.title" is-link @click="cellCk(i.title)" />
		</van-cell-group>
	</view>
	<van-popup v-model:show="showRoles" class="pCard">
		<van-radio-group v-model="checkRoles">
			<van-cell-group inset>
				<van-cell title="工作组" clickable @click="checkRoles = '0'">
					<template #right-icon>
						<van-radio name="0" />
					</template>
				</van-cell>
				<van-cell title="项目经理" clickable @click="checkRoles = '1'">
					<template #right-icon>
						<van-radio name="1" />
					</template>
				</van-cell>
				<van-cell title="甲方" clickable @click="checkRoles = '2'">
					<template #right-icon>
						<van-radio name="2" />
					</template>
				</van-cell>
			</van-cell-group>
		</van-radio-group>
		<view class="flex jce mgt40">
			<van-button type="primary" class="mgr20">确定</van-button>
			<van-button type="default" @click="showRoles = false">取消</van-button>
		</view>
	</van-popup>
	<van-popup v-model:show="showSet" class="pCard">
		<view class=""></view>
	</van-popup>
</template>

<script setup>
import req from '/common/js/req.js';
import { onMounted, ref } from 'vue';
import navCard from '../../components/nav/navCard.vue';
const cellList = [
	{ title: '我的项目', toLink: '' },
	{ title: '新建项目', toLink: '' },
	{ title: '更改身份', toLink: '' },
	{ title: '设置', toLink: '' }
];

const checkRoles = ref('0');
const showRoles = ref(false);
const showSet = ref(false);
function cellCk(title) {
	switch (title) {
		case '我的项目':
			toPage('/pages/user/myProject');
			break;
		case '新建项目':
			toPage('/pages/from/createdPage');
			break;
		case '更改身份':
			showRoles.value = true;
			break;
		case '设置':
			showSet.value = true;
			break;
	}
}
function toPage(url) {
	uni.navigateTo({
		url
	});
}
//获取用户信息
const navcard = ref();
function cf(tip) {
	req('getRolesList', { tip }).then((res) => {
		// console.log(navcard.value.user);
		console.log(res.data.data[0].username);
		navcard.value.user.username = res.data.data[0].username;
		navcard.value.user.roles = res.data.data[0].role[0];
	});
}

onMounted(() => {
	cf('getmyRoles');
});
</script>

<style lang="scss">
.pCard {
	padding: 40rpx;
	width: 600px;
}
</style>
